package com.spe.shangcheng.search.crontroller;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.DateFormat;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;

import java.util.Date;
import java.util.List;

/**
 * @author ：spe
 * @description：TODO
 * @date ：2024/11/25 21:41
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
//indexName 索引库名称 名字如果是字母那么必须是小写字母
//createIndex 是否创建索引
@Document(indexName = "student",createIndex = true)
public class Student {

    @Id
    @Field(store = true, type = FieldType.Keyword)
    private String sId;

    @Field(store = true, type = FieldType.Keyword)
    private String sName;

    @Field(store = true, type = FieldType.Text, analyzer = "ik_smart")
    //Text可以分词 ik_smart=粗粒度分词 ik_max_word 为细粒度分词
    private String sAddress;

    @Field(index = false, store = true, type = FieldType.Integer)
    private Integer sAge;

    @Field(index = false, store = true, type = FieldType.Date, format = DateFormat.basic_date_time)
    private Date sCreateTime;

    @Field(type = FieldType.Keyword)
    private String[] sCourseList; //数组类型 由数组中第一个非空值决定(这里数组和集合一个意思了)

    @Field(type = FieldType.Keyword)
    private List<String> sColorList; //集合类型 由数组中第一个非空值决定

}

